package com.atm.atmsys.controller.usersigController;

import com.atm.atmsys.Service.Imp.TRTCService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TRTCController {

    @Autowired
    private TRTCService trtcService;

    /**
     * 生成 UserSig
     *
     * @param userid 用户 ID
     * @param expire 有效期（秒）
     * @return UserSig
     */
    @GetMapping("/generateUserSig")
    public String generateUserSig(@RequestParam String userid, @RequestParam long expire) {
        return trtcService.generateUserSig(userid, expire);
    }

    /**
     * 生成 PrivateMapKey（数字房间号）
     *
     * @param userid       用户 ID
     * @param expire       有效期（秒）
     * @param roomid       房间号
     * @param privilegeMap 权限位
     * @return PrivateMapKey
     */
    @GetMapping("/generatePrivateMapKey")
    public String generatePrivateMapKey(@RequestParam String userid, @RequestParam long expire,
                                        @RequestParam long roomid, @RequestParam long privilegeMap) {
        return trtcService.generatePrivateMapKey(userid, expire, roomid, privilegeMap);
    }

    /**
     * 生成 PrivateMapKey（字符串房间号）
     *
     * @param userid       用户 ID
     * @param expire       有效期（秒）
     * @param roomstr      字符串房间号
     * @param privilegeMap 权限位
     * @return PrivateMapKey
     */
    @GetMapping("/generatePrivateMapKeyWithStringRoomID")
    public String generatePrivateMapKeyWithStringRoomID(@RequestParam String userid, @RequestParam long expire,
                                                        @RequestParam String roomstr, @RequestParam long privilegeMap) {
        return trtcService.generatePrivateMapKeyWithStringRoomID(userid, expire, roomstr, privilegeMap);
    }
}